#include <iostream>
#include"template.h"
using namespace std;

void test()
{
    B<int> b;
}



//非类（class)模版参数，只支持整形，且传参只允许给常量
template <size_t N>
class myArray{
    private:
        int arr[N];
};



void test1()
{
    int b =10;
    myArray<10> a;
    //myArray<int ,b>ab;  就会报错的案例
}





// 模版的特化
//特化例子如下
template <class T1,class T2>
class Data{
    public:
        void print(){
            std::cout<<"Data class T1,class T2"<<std::endl;
        }
        private:
    T1 t1;
    T2 t2;
};

//全特化
template <>
class Data<int ,double>{
    public:
    Data()
    {
        print();
    }
        void print(){
            std::cout<<"Data class Data int ,double"<<std::endl;
        }
};

// 偏特化
template <class T1>
class Data<T1,double>{
    public:
        Data()
        {
            print();
        }
        void print(){
            std::cout<<"Data class Data T1 ,double"<<std::endl;
        }
};


//偏特化（区别于直接用原始类型，而是用自定义相关的类）
template <class T1,class T2>
class Data< T1*, T2*>{
    public:
        Data()
        {
            print();
        }
        void print(){
            std::cout<<"Data class Data T1*,class T2*"<<std::endl;
        }
    private:
    T1 t1;
    T2 t2;
};

template<class T1>
T1 fuc(T1 a,T1 b)
{
    return a+b;
}
void test2()
{
    Data<int ,double> a;
    Data<double ,double> b;
    Data<double*,double*> c;

    //根据最匹配原则结果应该如下。
    //Data class Data int ,double
    // Data class Data T1 ,double
    // Data class Data T1*,class T2*
}

int main()
{
    test();
    return 0;
}